<?php
/**
 * Created by PhpStorm.
 * User: lijiao
 * Date: 15/7/18
 * Time: 上午10:34
 */

namespace app\controllers;

use Yii;
use yii\web\Controller;

class BaseController extends Controller
{
    protected function errorResponse($ecode='invalid.request' ,$msg = '非法请求'){
        $response = Yii::$app->response;
        $response->statusCode = 200;
//        $response->format = \yii\web\Response::FORMAT_JSON;

        $response->content = json_encode(array('code'=> 1, 'ecode'=>$ecode, 'emsg'=> $msg));

        Yii::$app->end();
    }

    protected function succResponse($arr = array()){
        $response = Yii::$app->response;
        $response->statusCode = 200;
//        $response->format = \yii\web\Response::FORMAT_JSON;

        $codeArr= array('code'=> 0);
        $response->content = Util::responseEncode(array_merge($codeArr, $arr));

        Yii::$app->end();
    }
}